﻿using Microsoft.Extensions.DependencyInjection;
using orders.Repository;
using orders.Repository.Impl;
using orders.Service;
using orders.Service.Impl;
using System.Data;

namespace orders.Extensions
{
    /// <summary>
    /// DI inject
    /// </summary>
    public static class ServiceExtension
    {

        public static IServiceCollection RegisterServices(
           this IServiceCollection services)
        {
            services.AddOptions();

            services.AddSingleton<IDataSource, DataSource>();
            //
            services.AddTransient(typeof(IBaseRepository<>), typeof(BaseRepository<>));

            // 注入servcie 
            services.AddTransient<IOrderService, OrderService>();

            // 注入repository
            services.AddTransient<IOrderRepository, OrderRepository>();

            return services;
        }
    }
}
